<#assign base = request.contextPath />
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>企业注册</title>
    <base id="base" href="${base}">
    <!-- Bootstrap -->
    <link href="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet">

    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/js/bootstrap.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.4.0/bootbox.min.js"></script>
    <script src="${base}/res/js/common.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="${base}/res/css/style.css"/>
    <link rel="stylesheet" type="text/css" href="${base}/res/css/body.css"/>
</head>
<body>
<div class="container">
    <section id="content" style="width: 600px;">
        <form action="" id="regForm" class="reg">
            <h1>企业注册</h1>
            <div>
                <p>单位名称</p>
                <input type="text" placeholder="请输入企业名称" name="unitName" required autocomplete="new-password"/>
                <span class="red">*</span>
            </div>

            <div>
                <p>税号</p>
                <input type="text" placeholder="请输入您的税号" name="taxNo" required autocomplete="new-password"/>
                <span class="red">*</span>
            </div>

            <div>
                <p>注册地</p>
                <input type="text" placeholder="请输入企业注册地区" name="registration" required autocomplete="new-password"/>
                <span class="red">*</span>
            </div>


            <div>
                <p>联系人</p>
                <input type="text" placeholder="请输入企业联系人姓名" name="contact" required autocomplete="new-password"/>
                <span class="red">*</span>
            </div>

            <div>
                <p>电话号码</p>
                <input type="text" placeholder="请输入企业联系人手机号码" name="tel" required
                       data-verification-type="mobile"
                       autocomplete="new-password"/>
                <span class="red">*</span>
            </div>

            <div>
                <p>联系地址</p>
                <input type="text" placeholder="请输入企业联系人地址" name="address" required autocomplete="new-password"/>
                <span class="red">*</span>
            </div>

            <div>
                <p>用户名</p>
                <input type="text" placeholder="请输入登录账号" name="username" required autocomplete="new-password"/>
                <span class="red">*</span>
            </div>

            <div>
                <p>密码</p>
                <input type="password" placeholder="请输入8-16位的登录密码" name="password" required autocomplete="new-password"
                       minlength="8"/>
                <span class="red">*</span>
            </div>

            <div>
                <p>注册资金</p>
                <input type="text" placeholder="请输入企业注册资金" name="registeredCapital" autocomplete="new-password"/>
                <span class="red">&nbsp;</span>
            </div>

            <div>
                <p>主营业务</p>
                <input type="text" placeholder="请输入您的主要经营业务" name="business" autocomplete="new-password"/>
                <span class="red">&nbsp;</span>
            </div>

            <div>
                <p>自有车队规模</p>
                <input type="text" placeholder="请输入您现在的车队规模" name="scale" autocomplete="new-password"/>
                <span class="red">&nbsp;</span>
            </div>

            <div>
                <p>主营线路</p>
                <input type="text" placeholder="请输入您主营路线" name="mainLine" autocomplete="new-password"/>
                <span class="red">&nbsp;</span>
            </div>

            <div>
                <a href="${base}/login">登录</a>
                <input type="submit" value="提交" id="js-btn-login"/>
            </div>
        </form>
    </section>
</div>
</body>
</html>

<script type="text/javascript">
    $(document).ready(function () {
        $('#regForm').submit(function () {
            var formData = {};
            var flag = true;
            $(this).find('input').each(function () {
                if ($(this).attr('data-verification-type') === 'mobile') {
                    if (checkPhone(this.value)) {
                        bootbox.alert('电话号码有误');
                        flag = false;
                        return false;
                    }
                }

                if (this.name && this.name !== '') {
                    formData[this.name] = this.value;
                }
            });

            if (flag) {
                $.httpclient.post(API_UCENTER_USER_REG, JSON.stringify(formData), function (data) {
                    if (data.code === 'SUCCESS') {
                        bootbox.alert({
                            size: "small",
                            closeButton: false,
                            message: '恭喜注册成功，请点击确定登录',
                            callback: function () {
                                location.href = '/';
                            },
                            title: "注册成功"
                        });
                    } else {
                        bootbox.alert(data.message);
                    }
                })
                /*$.ajax({
                    type: 'post',
                    url: API_UCENTER_USER_REG,
                    contentType: 'application/json;utf-8',
                    data: JSON.stringify(formData),
                    success: function (data) {
                        loadingDialog.modal("hide");
                        if (data.code === 'SUCCESS') {
                            bootbox.alert({
                                size: "small",
                                closeButton: false,
                                message: '恭喜注册成功，请点击确定登录',
                                callback: function () {
                                    location.href = '/';
                                },
                                title: "注册成功"
                            });
                        } else {
                            bootbox.alert(data.message);
                        }
                    },
                    error: function (jqXHR) {
                        bootbox.alert(jqXHR.responseJSON.message);
                    }
                });*/
            }


            return false;
        });
    })
</script>
